﻿using AutoMapper;
using BW.WMS.Model;
using BW.WMS.RBAC;
using BW.WMS.WCL.DTO;
using BW.WMS.XKY;
using BW.WMS.XKY.DTO.Input;
using BW.WMS.XKY.DTO.Output;

namespace BW.WMS;

public class WMSApplicationAutoMapperProfile : Profile
{
    public WMSApplicationAutoMapperProfile()
    {
        /* You can configure your AutoMapper mapping configuration here.
         * Alternatively, you can split your mapping configurations
         * into multiple profile classes for a better organization. */
        CreateMap<UserModel, UserOutput>().ReverseMap();
        CreateMap<UserModel, UserInput>().ReverseMap();
        CreateMap<RoleModel, RoleInput>().ReverseMap();
        CreateMap<RoleModel, RoleOutput>().ReverseMap();
        CreateMap<Me_StCurDto, Me_StCur>().ReverseMap();
        CreateMap<CreateUpdateMe_Stcur, Me_StCur>().ReverseMap();
        
        // 库存管理相关映射
        CreateMap<Dm_Item, InventoryDetailDto>()
            .ForMember(dest => dest.ProductCode, opt => opt.MapFrom(src => src.Itemid))
            .ForMember(dest => dest.ProductName, opt => opt.MapFrom(src => src.Itemname))
            .ForMember(dest => dest.Status, opt => opt.MapFrom(src => src.Satus == 1 ? "启用" : "停用"))
            .ForMember(dest => dest.Specification, opt => opt.MapFrom(src => src.Itemspec))
            .ForMember(dest => dest.Barcode, opt => opt.MapFrom(src => "")); // Dm_Item没有Barcode字段
    }
}
